﻿using DeluxeSources.Practices.Models;
using Spire.Pdf;
using System;
using System.IO;
using System.Web;
using System.Web.Mvc;

namespace DeluxeSources.Practices.Controllers
{
    #region DynamicDataSourceController
    /// <summary>
    /// 动态数据源MVC控制器。
    /// </summary>
    public class DynamicDataSourceController : Controller
    {
        #region GenerateDynamicDataSource
        /// <summary>
        /// 生成动态数据源。
        /// </summary>
        /// <returns><see cref="ActionResult"/>对象实例。</returns>
        [ActionName("Generate")]
        public ActionResult GenerateDynamicDataSource()
        {
            return View(DynamicDataSourceDispatcher.GetDataSource());
        }
        #endregion

        #region ExportDataSourceToPdfDocument
        /// <summary>
        /// 导出数据源到PDF文档。
        /// </summary>
        /// <returns></returns>
        [ActionName("Export")]
        public RedirectResult ExportDataSourceToPdfDocument()
        {
            return this.Redirect(this.Url.Content("~/Handlers/ExportHandler.aspx?targetDataSourceUri=") + this.Request.QueryString["targetDataSourceUri"]);
        }
        #endregion
    }
    #endregion
}
